package com.wen.open.springframework.aop.aspectj;

import com.wen.open.springframework.aop.Pointcut;
import com.wen.open.springframework.aop.PointcutAdvisor;
import org.aopalliance.aop.Advice;

/**
 * 切点的访问者，注入构建AdvisedSupport所需要的信息
 * @author Wen
 * @date 2023/4/26 16:09
 */
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {
    //拦截后执行的方法
    private Advice advice;
    //方法匹配表达式
    private String expression;
    //切点表达式，提供匹配能力
    private AspectJExpressionPointcut pointcut;

    @Override
    public Advice getAdvice() {
        return advice;
    }

    @Override
    public Pointcut getPointcut() {
        if (pointcut == null) {
            pointcut = new AspectJExpressionPointcut(expression);
        }
        return pointcut;
    }


}
